<template>
    <div class="app-container">
        <el-row :gutter="20">
            <!--部门数据-->
            <el-col :span="4" :xs="24">
                <div class="head-container">
                    <el-input
                        v-model="deptName"
                        placeholder="请输入分类名称"
                        clearable
                        size="small"
                        prefix-icon="el-icon-search"
                        style="margin-bottom: 20px"
                    />
                </div>
                <div class="head-container leftTree">
                    <el-tree
                        :data="deptOptions"
                        :props="defaultProps"
                        :expand-on-click-node="false"
                        :filter-node-method="filterNode"
                        ref="tree"
                        default-expand-all
                        @node-click="handleNodeClick"
                    />
                </div>
            </el-col>
            <!--用户数据-->
            <el-col :span="20" :xs="24">
                <el-row :gutter="10" class="mb8">
                    <el-col :span="4">
                        <el-input
                            v-model="queryParams.searchValue"
                            placeholder="请输入服务名称"
                            clearable
                            size="small"
                            prefix-icon="el-icon-search"
                            style="margin-bottom: 20px"
                            @keyup.enter.native="getList"
                        />
                    </el-col>
                    <el-col :span="1.5">
                        <el-button
                            type="primary"
                            icon="el-icon-search"
                            size="small"
                            @click="getList"
                            >搜索</el-button
                        >
                        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                    </el-col>
                </el-row>
                <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                        <el-button
                            type="primary"
                            icon="el-icon-plus"
                            size="mini"
                            @click="handleAdd"
                            >新增</el-button
                        >
                    </el-col>
                  <!--  <el-col :span="1.5">
                        <el-button
                            type="success"
                            icon="el-icon-edit"
                            size="mini"
                            :disabled="single"
                            @click="handleUpdate"
                            >修改</el-button
                        >
                    </el-col> -->
                    <el-col :span="1.5">
                        <el-button
                            type="danger"
                            icon="el-icon-delete"
                            size="mini"
                            :disabled="multiple"
                            @click="handleDelete"
                            >删除</el-button
                        >
                    </el-col>
                    <right-toolbar
                        :showSearch.sync="showSearch"
                        @queryTable="getList"
                    ></right-toolbar>
                </el-row>
                <el-table
                    v-loading="loading"
                    :data="userList"
                    @selection-change="handleSelectionChange"
                >
                    <el-table-column type="selection" width="50" />

                  <el-table-column
                    label="服务名"
                    prop="serviceName"
                    :show-overflow-tooltip="true"
                  />
                  <el-table-column
                      label="编码"
                      prop="code"
                      :show-overflow-tooltip="true"
                  />
                  <el-table-column
                    label="是否信创"
                    prop="serviceName"
                    :show-overflow-tooltip="true"
                    width="100"
                  >
                    <template slot-scope="scope">
                      <el-tag v-if="scope.row.isXc == true" type="danger" effect="plain">信创</el-tag>
                      <el-tag v-else type="info" effect="plain">非信创</el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="分类编码"
                    prop="serviceNumber"
                    :show-overflow-tooltip="true"
                    width="200"
                  />

                  <el-table-column
                    label="云服务商"
                    width="300"
                    class-name="small-padding fixed-width"
                  >
                    <template slot-scope="scope">
                      <el-tag v-for="cloud in scope.row.priceList" v-if="cloud.status=='1'" style="margin: 0px 2px; cursor: pointer;" :type="getSupplierClass(cloud)">
                        {{ cloud.cloudSupplierName }}
                      </el-tag>
                    </template>
                  </el-table-column>

                    <el-table-column
                        label="操作"
                        width="100"
                        class-name="small-padding fixed-width"
                    >
                        <template slot-scope="scope">
                            <el-button
                                v-if="scope.row.userId !== 1"
                                size="mini"
                                type="text"
                                icon="el-icon-edit"
                                @click="handleUpdate(scope.row)"
                                >修改</el-button
                            >
                            <el-button
                                size="mini"
                                type="text"
                                icon="el-icon-delete"
                                @click="handleDelete(scope.row)"
                                >删除</el-button
                            >
                        </template>
                    </el-table-column>
                </el-table>

                <pagination
                    v-show="total > 0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
                />
            </el-col>
        </el-row>
        <!-- 价格弹出框 -->
        <el-dialog
            title="价格查询"
            :visible.sync="Pricedialog"
            width="80%"
            :before-close="PriceClose"
        >
            <el-row style="padding: 20px; padding-left: 0px">
                <el-col :span="4">
                </el-col>
            </el-row>
            <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button
                        type="primary"
                        icon="el-icon-plus"
                        size="mini"
                        @click="PricehandleAdd"
                        >新增</el-button
                    >
                </el-col>
                <el-col :span="1.5">
                    <el-button
                        type="success"
                        icon="el-icon-edit"
                        size="mini"
                        :disabled="single"
                        @click="PricehandleUpdate"
                        >修改</el-button
                    >
                </el-col>
                <el-col :span="1.5">
                    <el-button
                        type="danger"
                        icon="el-icon-delete"
                        size="mini"
                        :disabled="multiple"
                        @click="PricehandleDelete"
                        >删除</el-button
                    >
                </el-col>
            </el-row>
            <el-table
                ref="singleTable"
                :data="PriceList"
                @selection-change="PricehandleSelectionChange"
                style="width: 100%"
            >
                <el-table-column type="selection" width="50" />
                <el-table-column type="index" width="50"> </el-table-column>
                <el-table-column property="cloudSupplier" label="云服务商" />
                <el-table-column property="startDate" label="开始日期" />
                <el-table-column property="endDate" label="结束日期" />
                <el-table-column property="price" label="价格" />
                <el-table-column property="unit" label="计量单位" />
                <el-table-column label="状态">
                    <template slot-scope="scope">
                        <el-switch
                            v-model="scope.row.status"
                            active-value="0"
                            inactive-value="1"
                            @change="handleStatusChange(scope.row)"
                        ></el-switch>
                    </template>
                </el-table-column>
                <el-table-column
                    label="操作"
                    width="200"
                    class-name="small-padding fixed-width"
                >
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-edit"
                            @click="PricehandleUpdate(scope.row)"
                            >修改</el-button
                        >
                        <el-button
                            size="mini"
                            type="text"
                            icon="el-icon-delete"
                            @click="PricehandleDelete(scope.row)"
                            >删除</el-button
                        >
                    </template>
                </el-table-column>
            </el-table>
            <pagination
                v-show="totals > 0"
                :total="totals"
                :page.sync="queryParamss.pageNum"
                :limit.sync="queryParamss.pageSize"
                @pagination="PriceLists"
            />
        </el-dialog>

        <!-- 新增云服务商价格 -->
        <el-dialog
            :title="Pricetitle"
            :visible.sync="Priceopen"
            width="50%"
            append-to-body
            >.
            <el-form
                ref="forms"
                :model="forms"
                :rules="ruless"
                label-width="80px"
            >
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="云服务商" prop="cloudSupplier">
                            <!-- <el-input
                                v-model="forms.cloudSupplier"
                                placeholder="请输入云服务商"
                            /> -->
                            <el-select
                                style="width: 100%"
                                v-model="forms.cloudSupplier"
                                placeholder="请选择云服务商"
                            >
                                <el-option
                                    v-for="item in logicLists"
                                    :key="item.cloudSupplier"
                                    :label="item.cloudSupplierName"
                                    :value="item.cloudSupplierName"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="价格" prop="price">
                            <el-input
                                v-model="forms.price"
                                placeholder="请输入价格"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="开始时间" prop="startDate">
                            <!-- <el-input
                                v-model="forms.startDate"
                                placeholder="请输入开始时间"
                            /> -->
                            <el-date-picker
                                style="width: 100%"
                                v-model="forms.startDate"
                                align="right"
                                type="date"
                                format="yyyy 年 MM 月 dd 日"
                                value-format="yyyy-MM-dd"
                                placeholder="选择开始时间"
                                :picker-options="pickerOptions1"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="结束时间" prop="endDate">
                            <!-- <el-input
                                v-model="forms.endDate"
                                placeholder="请输入结束时间"
                            /> -->
                            <el-date-picker
                                style="width: 100%"
                                v-model="forms.endDate"
                                align="right"
                                type="date"
                                format="yyyy 年 MM 月 dd 日"
                                value-format="yyyy-MM-dd"
                                placeholder="选择结束时间"
                                :picker-options="pickerOptions1"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="计量单位" prop="unit">
                            <el-input
                                v-model="forms.unit"
                                placeholder="请输入计量单位"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="价格状态">
                            <el-radio-group v-model="forms.status">
                                <el-radio
                                    v-for="dict in statusOptions"
                                    :key="dict.dictValue"
                                    :label="dict.dictValue"
                                >{{ dict.dictLabel }}</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitPrice">确 认</el-button>
                <el-button @click="cancelPrice">取 消</el-button>
            </div>
        </el-dialog>

        <!-- 新增云服务商 -->
        <el-dialog
            :title="title"
            :visible.sync="open"
            width="50%"
            append-to-body
            >.
            <el-form ref="form" :model="form" :rules="rules" label-width="140px">
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="服务分类" prop="serviceClazz">
                            <treeselect
                                v-model="form.serviceClazz"
                                :options="deptOptions"
                                :show-count="true"
                                @select="serviceClazzChenge"
                                placeholder="请输入服务名称"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="服务名称" prop="serviceName">
                            <el-input
                                v-model="form.serviceName"
                                placeholder="请输入服务名称"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="服务编码" prop="code">
                            <el-input
                                :min="0"
                                v-model="form.code"
                                placeholder="请输入服务编码"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="16">
                        <el-form-item label="是否信创">
                            <el-radio-group v-model="form.isXc">
                            <el-radio label="false">非信创</el-radio>
                            <el-radio label="true">信创</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-show="PhysicalServerState">
                    <el-col :span="8">
                        <el-form-item label="CPU个数" prop="cpuCount">
                            <el-input
                                v-model="form.cpuCount"
                                placeholder="请输入CPU个数"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="CPU说明" prop="cpuRemark">
                            <el-input
                                type="textarea"
                                v-model="form.cpuRemark"
                                placeholder="请输入CPU说明"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-show="PhysicalServerState">
                    <el-col :span="8">
                        <el-form-item label="硬盘大小G" prop="diskSize">
                            <el-input
                                v-model="form.diskSize"
                                placeholder="请输入硬盘大小G"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="硬盘说明" prop="diskRemark">
                            <el-input
                                type="textarea"
                                v-model="form.diskRemark"
                                placeholder="请输入硬盘说明"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-show="PhysicalServerState">
                    <el-col :span="8">
                        <el-form-item label="内存大小G" prop="memSize">
                            <el-input
                                v-model="form.memSize"
                                placeholder="请输入内存大小G"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="内存说明" prop="memRemark">
                            <el-input
                                type="textarea"
                                v-model="form.memRemark"
                                placeholder="请输入内存说明"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-for="(item,index) in priceList" :key="index">
                    <el-col :span="24" style="display: flex">
                        <el-form-item :label="item.cloudSupplierName+' 单价(元/天)'" prop="price">
                          <el-switch
                            v-model="item.status"
                            active-value="1"
                            inactive-value="0">
                          </el-switch>

                          <el-input
                            v-show="item.status=='1'"
                            style="display: inline;"
                            :min="0"
                            type="number"
                            v-model="item.price"
                            placeholder="请输入单价"
                          />

                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="8">
                        <el-form-item label="排序" prop="sort">
                            <el-input-number
                                v-model="form.sort"
                                :min="0"
                                style="width: 100%"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="16">
                        <el-form-item label="计量单价" prop="unit">
                            <el-select
                                v-model="form.unit"
                                placeholder="请选择计量单价"
                                clearable
                                size="small"
                                style="width: 100%"
                            >
                                <el-option
                                    v-for="dict in PriceUnit"
                                    :key="dict.dictValue"
                                    :label="dict.dictLabel"
                                    :value="dict.dictValue"
                                />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="描述" prop="remark">
                            <el-input
                                v-model="form.remark"
                                type="textarea"
                                placeholder="请输入描述"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitcloudServiceProvider"
                    >确 认</el-button
                >
                <el-button @click="cancelcloudServiceProvider">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import {
    treeselect,
    PostCatalog,
    PutCatalog,
    CatalogList,
    DelectCatalog,
    CatalogId,
    PriceList,
    DelectPrice,
    PriceIds,
    PostPrice,
    PutPrice,
    logicList,
} from "@/api/basic/services";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
    name: "Services",
    components: { Treeselect },
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            Priceids: [],
            deptName: "",
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 总条数
            totals: 0,
            // 部门树选项
            deptOptions: undefined,
            price1:[],
            price2:[],
            price3:[],
            priceList : [],
            // 表单参数
            form: {
                sort : 1,
                priceList : [],
                isXc:'false'
            },
            forms: {},
            defaultProps: {
                children: "children",
                label: "label",
            },
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                deptName:null,
                serviceClazz: "",
                searchValue: "",
            },
            label : '',
            // 查询参数
            queryParamss: {
                pageNum: 1,
                pageSize: 10,
                cloudSupplier: "",
            },
            // 服务商数据列表
            userList: [],
            // 价格数据列表
            PriceList: [],
            // 价格弹窗状态
            Pricedialog: false,
            open: false,
            title: "",
            Priceopen: false,
            Pricetitle: "",
            rules: {
                serviceClazz: [
                    {
                        required: true,
                        message: "请选择服务分类",
                        trigger: "change",
                    },
                ],
                serviceName: [
                    {
                        required: true,
                        message: "请输入服务名称",
                        trigger: "blur",
                    },
                ],
                code: [
                    {
                        required: true,
                        message: "请输入服务编码",
                        trigger: "blur",
                    },
                ],
                serviceNumber: [
                    {
                        required: true,
                        message: "请输入服务编码",
                        trigger: "blur",
                    },
                ],
            },
            ruless: {},
            // 价格ID
            Priceid: "",
            // 字典参数
            statusOptions: [],
            PriceUnit: [],
            // 云服务商下拉数据
            logicLists: [],
            pickerOptions1: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [
                    {
                        text: "今天",
                        onClick(picker) {
                            picker.$emit("pick", new Date());
                        },
                    },
                    {
                        text: "昨天",
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24);
                            picker.$emit("pick", date);
                        },
                    },
                    {
                        text: "一周前",
                        onClick(picker) {
                            const date = new Date();
                            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit("pick", date);
                        },
                    },
                ],
            },
            PhysicalServerState: true,
        };
    },
    watch: {
        // 根据名称筛选部门树
        deptName(val) {
            this.$refs.tree.filter(val);
        },
    },
    created() {
        this.GetlogicLists()
        this.getList();
        this.getTreeselect();
        this.getDicts("sys_normal_disable").then((response) => {
            this.statusOptions = response.data;
        });
        this.getDicts("price_unit").then((response) => {
            this.PriceUnit = response.data;
        });
    },
    methods: {
      resetQuery(){
        this.queryParams.searchValue=''
        this.queryParams.pageNum=1
        this.getList()
      },
        // 查询云服务商分类
        GetlogicLists(){
            logicList().then(res=>{
                let logicListAll = []
                res.rows.forEach(item => {
                    logicListAll.push({
                        cloudSupplier : item.cloudSupplier,
                        cloudSupplierName : item.cloudSupplierName,
                        price : null,
                    })
                });
                this.form = {}
                this.form.sort = 1
                this.form.priceList = logicListAll
                this.form.isXc = 'false'
                this.priceList = logicListAll
            })
        },
        handleChange(Value) {
        },
        serviceClazzChenge(row) {
            this.form.serviceNumber = row.code
            if (row.label.indexOf("高性能服务器") != -1) {
                this.PhysicalServerState = true;
            } else {
                this.PhysicalServerState = false;
            }
        },
        PriceUnitChenge(row) {
            return this.selectDictLabel(this.PriceUnit, row.unit);
        },
        /** 转换部门数据结构 */
        normalizer(node) {
            if (node.children && !node.children.length) {
                delete node.children;
            }
            return {
                id: node.id,
                label: node.label,
                children: node.children,
            };
        },
        /** 新增按钮操作 */
        handleAdd() {
            // this.form = {
            //     sort : 1
            // };
            this.GetlogicLists()
            setTimeout(() => {
                if(this.queryParams.serviceClazz){
                this.form.serviceClazz = this.queryParams.serviceClazz
                this.form.serviceNumber = this.queryParams.serviceNumber
                console.log(this.queryParams,88)
                }
                if (this.label.indexOf("高性能服务器") != -1) {
                    this.PhysicalServerState = true;
                } else {
                    this.PhysicalServerState = false;
                }

                this.open = true;
                this.title = "新增服务";
                this.getTreeselect();
            }, 200);
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            var id = row.id || this.ids;
            this.open = true;
            this.title = "修改服务";
            CatalogId(id).then((res) => {
                this.form = res.data;
                this.form.isXc = res.data.isXc + ''
                this.priceList = res.data.priceList
                // this.form.id = 101
                if (this.form.serviceName.indexOf('高性能服务器') != -1) {
                    this.PhysicalServerState = true;
                } else {
                    this.PhysicalServerState = false;
                }
                treeselect().then((response) => {
                    this.deptOptions = response.data;
                });
            });
        },
        handleDelete(row) {
            var ConfirmName = row.serviceName
                ? `是否确认删除名称为${row.serviceName}的数据项?`
                : `是否确认删除${this.ids.length}项数据?`;
            const serviceId = row.id || this.ids.join(",");
            this.$confirm(ConfirmName, "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(function () {
                    return DelectCatalog(serviceId);
                })
                .then(() => {
                    this.getList();
                    this.msgSuccess("删除成功");
                });
        },
        // 提交新增云服务商
        submitcloudServiceProvider() {
            this.$refs["form"].validate((valid) => {
                if (valid) {
                    if (this.form.id != undefined) {
                        PutCatalog(this.form).then((response) => {
                            this.msgSuccess("修改成功");
                            this.open = false;
                            this.getList();
                        });
                    } else {
                        PostCatalog(this.form).then((response) => {
                            this.msgSuccess("新增成功");
                            this.open = false;
                            this.getList();
                        });
                    }
                }
            });
        },
        // 取消提交云服务商
        cancelcloudServiceProvider() {
            this.open = false;
        },
        // 提交新增价格
        submitPrice() {
            this.forms.catalogId = this.Priceid;
            this.$refs["forms"].validate((valid) => {
                if (valid) {
                    if (this.forms.id != undefined) {
                        PutPrice(this.forms).then((response) => {
                            this.msgSuccess("修改成功");
                            this.Priceopen = false;
                            PriceList(
                                this.Priceid,
                                "",
                                this.queryParamss.pageNum,
                                this.queryParamss.pageSize
                            ).then((res) => {
                                this.PriceList = res.rows;
                                this.totals = res.total;
                                this.Pricedialog = true;
                            });
                        });
                    } else {
                        PostPrice(this.forms).then((response) => {
                            this.msgSuccess("新增成功");
                            this.Priceopen = false;
                            PriceList(
                                this.Priceid,
                                "",
                                this.queryParamss.pageNum,
                                this.queryParamss.pageSize
                            ).then((res) => {
                                this.PriceList = res.rows;
                                this.totals = res.total;
                                this.Pricedialog = true;
                            });
                        });
                    }
                }
            });
        },
        // 取消提交新增价格
        cancelPrice() {
            this.Priceopen = false;
        },
        /** 查询用户列表 */
        getList() {
            this.loading = true;
            CatalogList(this.queryParams).then((response) => {
                this.userList = response.rows;
                this.total = response.total;
                // this.msgSuccess(response.msg);
                this.loading = false;
            });
        },
        PriceLists() {
            PriceList(
                this.Priceid,
                "",
                this.queryParamss.pageNum,
                this.queryParamss.pageSize
            ).then((res) => {
                this.PriceList = res.rows;
                this.totals = res.total;
                this.Pricedialog = true;
            });
        },
        /** 查询部门下拉树结构 */
        getTreeselect() {
            treeselect().then((response) => {
                this.deptOptions = response.data;
            });
        },
        // 筛选节点
        filterNode(value, data) {
            if (!value) return true;
            return data.label.indexOf(value) !== -1;
        },
        // 节点单击事件
        handleNodeClick(data) {
            this.queryParams.serviceClazz = data.id;
            this.queryParams.serviceNumber = data.code
            this.label = data.label
            this.getList();
        },
        PricehandleQuery() {
            if (this.queryParamss.cloudSupplier == "全部") {
                this.queryParamss.cloudSupplier = "";
            }
            PriceList(
                this.Priceid,
                this.queryParamss.cloudSupplier,
                this.queryParamss.pageNum,
                this.queryParamss.pageSize
            ).then((res) => {
                this.PriceList = res.rows;
                this.totals = res.total;
                this.Pricedialog = true;
            });
        },
        // 价格查询
        InquiryPrice(item) {
            this.Priceid = item.id;
            PriceList(
                item.id,
                "",
                this.queryParamss.pageNum,
                this.queryParamss.pageSize
            ).then((res) => {
                this.PriceList = res.rows;
                this.totals = res.total;
                this.Pricedialog = true;
            });
        },
        // 价格查询弹窗关闭
        PriceClose() {
            this.Pricedialog = false;
        },
        // 价格启用状态
        handleStatusChange(row) {
            let text = row.status === "0" ? "启用" : "停用";
            this.$confirm(
                '确认要"' + text + '""' + row.cloudSupplier + '"用户吗?',
                "警告",
                {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                }
            )
                .then(function () {
                    return PutPrice(row);
                })
                .then(() => {
                    this.msgSuccess(text + "成功");
                })
                .catch(function () {
                    row.status = row.status === "0" ? "1" : "0";
                });
        },
        // 价格修改
        PricehandleUpdate(row) {
            var id = row.id || this.Priceids;
            this.Priceopen = true;
            this.Pricetitle = "修改云服务商价格";
            PriceIds(id).then((res) => {
                this.forms = res.data;
            });
        },
        // 价格删除
        PricehandleDelete(row) {
            var ConfirmName = row.cloudSupplier
                ? `是否确认删除名称为${row.cloudSupplier}的数据项?`
                : `是否确认删除${this.Priceids.length}项数据?`;
            const PriceId = row.id || this.Priceids.join(",");
            this.$confirm(ConfirmName, "警告", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(function () {
                    return DelectPrice(PriceId);
                })
                .then(() => {
                    PriceList(
                        this.Priceid,
                        "",
                        this.queryParamss.pageNum,
                        this.queryParamss.pageSize
                    ).then((res) => {
                        this.PriceList = res.rows;
                        this.totals = res.total;
                        this.Pricedialog = true;
                    });
                    this.msgSuccess("删除成功");
                });
        },
        // 价格新增
        PricehandleAdd() {
            this.forms = {};
            this.forms.status = "0";
            this.Priceopen = true;
            this.Pricetitle = "新增云服务商";
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.id);
            this.single = selection.length != 1;
            this.multiple = !selection.length;
        },
        PricehandleSelectionChange(selection) {
            this.Priceids = selection.map((item) => item.id);
            this.single = selection.length != 1;
            this.multiple = !selection.length;
        },
      getSupplierClass(cloud){
          if(cloud.cloudSupplier=="Inspur"){
            return null;
          }else if(cloud.cloudSupplier=="Sugon"){
            return "info";
          }else if(cloud.cloudSupplier=="H3C"){
            return "success";
          }
      },
    },
};
</script>
<style scoped lang="scss">
.app-container {
    .leftTree {
        height: 80vh;
        overflow-y: auto;
    }
}
</style>
